<template>
  <div class="bgcolor" :style="{ left: left }" v-show="shows">
    <!-- <div class="top" :style="{'background': 'url('+ bgimg +')'}">  -->
    <div class="top">
      <img :src="avatarUrl" alt="" @click="editMage" v-if="avatarUrl" />
      <div class="username">
        <span>{{ nickname }}</span>
      </div>
    </div>
    <div class="bottomImg">
      <ul class="mages">
        <li>
          <span class="iconfont icon-xiaoxi"></span>
          <p>我的消息</p>
        </li>
        <li>
          <span class="iconfont icon-VIP"></span>
          <p>VIP会员</p>
        </li>
        <li>
          <span class="iconfont icon-shangcheng"></span>
          <p>商城</p>
        </li>
        <li>
          <span class="iconfont icon-liuliang"></span>
          <p>在线听歌免流量</p>
        </li>
      </ul>
      <div class="grayline"></div>
      <ul class="myfriends">
        <li>
          <span class="iconfont icon-biaoqing"></span>
          <p>我的好友</p>
        </li>
        <li>
          <span class="iconfont icon-icon-test1"></span>
          <p>附近的人</p>
        </li>
      </ul>
      <div class="grayline"></div>
      <ul class="other">
        <li>
          <span class="iconfont icon-pifu"></span>
          <p>个性换肤</p>
        </li>
        <li>
          <span class="iconfont icon-tinggeshiqu"></span>
          <p>听歌识曲</p>
        </li>
        <li>
          <span class="iconfont icon-dingshi"></span>
          <p>定时停止播放</p>
        </li>
        <li>
          <span class="iconfont icon-saoyisao"></span>
          <p>扫一扫</p>
        </li>
        <li>
          <span class="iconfont icon-icon-test"></span>
          <p>音乐闹钟</p>
        </li>
      </ul>
      <div class="person_bottom">
        <div><span class="iconfont icon-yejian"></span> 夜间模式</div>
        <div><span class="iconfont icon-shezhi1"></span> 设置</div>
        <div @click="exit"><span class="iconfont icon-tuichu"></span> 退出</div>
      </div>
      <div></div>
    </div>
  </div>
</template>

<script>
import { getUserDetail } from "../api/base.js";
export default {
  props: ["left", "shows"],
  data() {
    return {
      leftoo: null,
      show: false,
      avatarUrl: [],
      nickname: null,
      bgimg: null,
    };
  },
  methods: {
    // 退出
    exit() {
      this.leftoo = "-80%";
      this.show = false;
      this.$emit("exit", { left: this.leftoo, show: this.show });
    },
    // 登录后调用此接口 ,可获取用户账号信息
    getUserDetailFn(id) {
      getUserDetail({ uid: id }).then((data) => {
        console.log("用户账号信息", data);
            this.avatarUrl = data.profile.avatarUrl;
          this.nickname = data.profile.nickname;
          this.bgimg = data.profile.backgroundUrl;
        // console.log("用户账号信息id", data.account.id);
      });
    },
    editMage() {
      this.$router.push("/editMages");
      this.$emit("exit", { left: this.leftoo, show: this.show });
    },
  },
  created() {
    this.getUserDetailFn(window.localStorage.getItem("uid"));
  },
};
</script>

<style lang="less" scoped>
.bgcolor {
  width: 80%;
  background-color: #fff;
  position: absolute;
  top: 0px;
  left: -80%;
  z-index: 9999;
  color: #4e4c4f;
  transition: left 0.5s;
  .top {
    height: 160px;
    background: linear-gradient(to right, #d4473c, #b4534c);
    position: relative;
    line-height: 160px;
    text-align: center;
    img {
      width: 80px;
      height: 80px;
      background-color: pink;
      border-radius: 50%;
      position: absolute;
      top: 50%;
      left: 20px;
      transform: translateY(-50%);
    }
    .username {
      color: #fff;
      font-size: 20px;
    }
  }
  .bottomImg {
    ul {
      padding: 0 10px;
      font-weight: 700;
      li {
        height: 40px;
        display: flex;
        align-items: center;
        p {
          margin-left: 14px;
        }
      }
    }
  }
  .grayline {
    height: 10px;
    width: 100%;
    background-color: #f4f2f5;
  }
  .person_bottom {
    height: 60px;
    border-bottom: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 10px;
    font-weight: 700;
    div {
      &:first-child {
        flex: 40%;
      }
      flex: 30%;
    }
    .icon-tuichu {
      font-size: 22px;
      vertical-align: middle;
    }
  }
}
</style>